# Contributor: Ted Trask <ttrask01@yahoo.com>
# Maintainer: Ted Trask <ttrask01@yahoo.com>
_luaversion="5.2"
pkgname=acf-core
pkgver=0.22.0
pkgrel=0
pkgdesc="A web-based system administration interface framework"
url="https://git.alpinelinux.org/cgit/acf/acf-core"
arch="noarch"
license="GPL-2.0"
install="$pkgname.post-upgrade"
depends="acf-jquery acf-lib acf-skins haserl-lua$_luaversion lua$_luaversion
	lua$_luaversion-posix lua$_luaversion-md5 lua-json4
	lua$_luaversion-subprocess"
source="https://dev.alpinelinux.org/archive/$pkgname/$pkgname-$pkgver.tar.xz"

package() {
	cd "$srcdir/$pkgname-$pkgver"
	sed "s~luadir=.*~luadir=\${prefix}/share/lua/$_luaversion/acf~" -i config.mk \
		|| return 1

	# fix shebang
	sed -i -e "1s:#!/usr/bin/haserl :#!/usr/bin/haserl-lua$_luaversion :" \
		www/cgi-bin/acf || return 1

	sed -i -e "1s:#!/usr/bin/lua.*:#!/usr/bin/lua$_luaversion:" \
		bin/acf-cli || return 1

	make DESTDIR="$pkgdir" install || return 1
	mkdir -p "$pkgdir"/etc/acf/skins
}
sha512sums="34f92f36cd3ecf71f7ab5c94cd35cb54eec195e04997091ebd131c04820cb4a0b3566c7a085e5282c38c6ad80b6b1558db7252fcf47c096811070e278f27a92e  acf-core-0.22.0.tar.xz"
